package org.jsrml.core.base.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.jsrml.common.persistence.StringIdBaseEntity;
import org.jsrml.common.util.UUIDGenerator;
import org.jsrml.core.base.entity.BaseStatus;
import org.jsrml.core.purchaser.command.SaveAdminCo;

@DynamicUpdate
@Entity
@Table(name = M.TABLE_PREFIX + "ADMIN")
@SuppressWarnings("serial")
public class Admin extends StringIdBaseEntity {
	
	private AdminInfo Info;
	
	@Column(name = "DESRC", columnDefinition = M.TEXT_COLUMN)
	private String desrc;

	
	private BaseStatus status;
	
	public void create(SaveAdminCo command){
		setId(UUIDGenerator.getUUID());
		if(getInfo()==null){
			setInfo(new AdminInfo());
		}
		getInfo().setName(command.getName());
		setDesrc(command.getDesrc());
		setStatus(new BaseStatus());
		getStatus().setRemove(false);
		getStatus().setCreateDate(new Date());
	}
	
	public AdminInfo getInfo() {
		return Info;
	}

	public void setInfo(AdminInfo info) {
		Info = info;
	}

	public String getDesrc() {
		return desrc;
	}

	public void setDesrc(String desrc) {
		this.desrc = desrc;
	}


	public BaseStatus getStatus() {
		return status;
	}

	public void setStatus(BaseStatus status) {
		this.status = status;
	}

}
